<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<title>home</title>
<style type="text/css">
html {
	height: 100%
}

body {
	height: 100%;
	margin: 0px;
	padding: 0px
}

#container {
	height: 94%;
}
</style>
<script type="text/javascript"
	src="${pageContext.request.contextPath }/home/js/jquery-2.2.2.min.js"></script>
</head>
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/admin/jquery-easyui-1.3.3/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/admin/jquery-easyui-1.3.3/themes/icon.css">
<script type="text/javascript"
	src="${pageContext.request.contextPath}/admin/jquery-easyui-1.3.3/jquery.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/admin/jquery-easyui-1.3.3/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/admin/jquery-easyui-1.3.3/locale/easyui-lang-zh_CN.js"></script>

<body>
<!-- 
[
{"id":"","name":"请选择..."},
{"id":"149de0e276344e10b91773939dd88a8d","name":"北京市"},
{"id":"43830620614943f4af891bd567ea8b02","name":"河北省"},
{"id":"e25e1219eb594668b641a7e799839af9","name":"河南省"}
]

[
{"name":"北京市","id":"149de0e276344e10b91773939dd88a8d"},
{"name":"河北省","id":"43830620614943f4af891bd567ea8b02"},
{"name":"河南省","id":"e25e1219eb594668b641a7e799839af9"}
]

 -->
	<div style="height: 34px">
		<form id="export" method="post"
			action="${pageContext.request.contextPath}/search/show">
			<td>所属省：</td>
			<td><input class="easyui-combobox" name="province" id="province"
				style="width: 148px; height: 25px"
				data-options="editable:false,panelHeight:200,valueField:'id',textField:'name',url:'${pageContext.request.contextPath}/province/provinceAll'" /></td>
			<td>所属市：</td>
			<td><input class="easyui-combobox" name="city" id="city"
				style="width: 148px; height: 25px"
				data-options="editable:false,panelHeight:200,valueField:'id',textField:'name',url:'${pageContext.request.contextPath}/city/cityAll'" />
			</td>
			<td>所属区：</td>
			<td><input class="easyui-combobox" name="area" id="area"
				style="width: 148px; height: 25px"
				data-options="editable:false,panelHeight:200,valueField:'id',textField:'name',url:'${pageContext.request.contextPath}/area/areaAll'" /></td>
			<td>名字：</td> <input type="text" name="product" id="sname" size="15"
				style="height: 18px" /> <a href="javascript:searchPatient()"
				class="easyui-linkbutton" iconCls="icon-search" plain="true"
				id="sub">搜索</a>
		</form>
		<script type="text/javascript">
			$(function(){
				$("#sub").click(function(){
					$("#export").submit();
				})
			})
		</script>
	</div>

	<script type="text/javascript">
		$(document).ready(function () {
			  //Start:设置combox的选择事件
			  $('#province').combobox({
			      onSelect: function () {
			    	  	var pid=$('#province').combobox('getValue');
			          	var url = '${pageContext.request.contextPath}/city/cityAll?pid='+pid;
			          	$('#city').combobox('reload', url);
			    	  }
			  });
			  $('#city').combobox({
			      onSelect: function () {
			    	  	var cid=$('#city').combobox('getValue');
			          	var url = '${pageContext.request.contextPath}/area/areaAll?cid='+cid;
			          	$('#area').combobox('reload', url);
			    	  }
			  });
			  
			  $('#area').combobox({
			      onSelect: function () {
			    	  	var aid=$('#area').combobox('getValue');
			          	var url = '${pageContext.request.contextPath}/product/productAll?aid='+aid;
			          	$('#product').combobox('reload', url);
			    	  }
			  });
		});
	</script>

	<div id="container"></div>
	<script type="text/javascript">
		var map;
		var jd;
		var wd;
		var lan1;
		var lan2;
		var wid1;
		var wid2;
		var data;
		var centerjd;
		var centerwd;
		function initialize(){
			var point;
			map = new BMap.Map("container",{minZoom:10,maxZoom:18}); // 创建地图实例  在这个div中创建一个地图     参数可以是元素id也可以是元素对象。
			if(typeof(centerjd)=='undefined'&&typeof(centerwd)=='undefined'){
				point = new BMap.Point(114.64202, 33.625607);
			}else{
				point = new BMap.Point(centerjd, centerwd); // 创建点坐标   Point类描述了一个地理坐标点，其中116.404表示经度，39.915表示纬度。 
			}
			map.centerAndZoom(point, 10); // 初始化地图，设置中心点坐标和地图级别
			map.enableScrollWheelZoom(); //开启鼠标滚动放大和缩小
			map.addControl(new BMap.OverviewMapControl()); //缩略地图控件
			map.setCurrentCity("北京"); // 仅当设置城市信息时，MapTypeControl的切换功能才能可用
			var stCtrl = new BMap.PanoramaControl();
			stCtrl.setOffset(new BMap.Size(40, 35));
			map.addControl(stCtrl);
			showInfo();
			lan1=sw.lng;
			lan2=ne.lng;
			wid1=sw.lat;
			wid2=ne.lat;
			if(typeof(data)=='undefined'){
				data={"lan1":lan1,"lan2":lan2,"wid1":wid1,"wid2":wid2};
			}
			var drivers =[];//存放标设备注点
			$.ajax({
				cache:false,
				type: "POST",
				data: data,
				url:'${pageContext.request.contextPath}/area/areaall.do',
				dataType:'json',
				success:function(data){
					var points=data.point;
					for(var i=0;i<points.length;i++){
						 obj=points[i];						 
						 jd=obj.jd;
						 wd=obj.wd;						 
						 var point = new BMap.Point(jd, wd);
						 var marker = new BMap.Marker(point); // 创建标注    其参数是一个点表示给哪一个点增加标注 
						 map.addOverlay(marker); //增加到地图中 	
						 addClickHandler(obj.id,marker);
						 
					}
					map.addEventListener("dragend",
							function showInfo() { //监听拖拽事件
									myreload();
							});
				},
				error : function(data) {
						alert('error!!!!');
					}
				});
		}
		function showInfo() {
			var cp = map.getBounds(); //返回map可视区域，以地理坐标表示
			sw = cp.getSouthWest(); //返回矩形区域的西南角
			ne = cp.getNorthEast(); //返回矩形区域的东北角

		}

		function myreload() {
			var cp = map.getBounds(); //返回map可视区域，以地理坐标表示
			var pt = cp.getCenter();
			sw = cp.getSouthWest(); //返回矩形区域的西南角
			ne = cp.getNorthEast();
			lan1 = sw.lng;
			lan2 = ne.lng;
			wid1 = sw.lat;
			wid2 = ne.lat;
			centerjd = pt.lng;
			centerwd = pt.lat;
			data = {
				"lan1" : lan1,
				"lan2" : lan2,
				"wid1" : wid1,
				"wid2" : wid2
			};
			initialize();
		}

		//异步加载百度地图  最后一个参数为调用函数名字
		function loadScript() {
				var script = document.createElement("script");
				script.type = "text/javascript";
				script.src = "http://api.map.baidu.com/api?v=2.0&ak=uA3xgKOZ7wxctg2PNzzOSY8VufRuFbAZ&callback=initialize";
				document.body.appendChild(script);
		}
		window.onload = loadScript();
		function addClickHandler(id,marker) {
			marker.addEventListener("click", function() {
				window.location.href="${pageContext.request.contextPath}/search/desc.do?id="+id;
			});
		}
	</script>
</body>
</html>